function ObjectLength(obj) {
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) size++;
    }
    return size;
};

$(document).ready(function() {
	$(window).resize(function() {
		if (!$("#button-autodj").length) {
			return false;
		}
		if ($("#menu").hasClass("margin")) {
			var collision = ($("#button-autodj").offset().left + $("#button-autodj").width()) - $("#menu").offset().left - 250;
		} else {
			var collision = ($("#button-autodj").offset().left + $("#button-autodj").width()) - $("#menu").offset().left;
		}
		if (collision > 0) {
			$("#menu").addClass("margin");
		} else {
			$("#menu").removeClass("margin");
		}
	});
	$(window).trigger("resize");
});